/**
 * Created by XQ on 2017/5/19.
 */
public class Sort {
    /**
     * 冒泡排序：相邻的作比较
     * @param args
     */
    public static void main(String[] args) {
        int arr[] ={10,80,90,60,5,0,6,4};
        int temp = 0;
        for (int i = 1; i < arr.length; i++) {
            for (int j = 0; j < arr.length-i; j++) {
                if (arr[j]>arr[j+1]){
                    temp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = temp;
                }
                System.out.print(arr[j]+" ");
            }
//            将移动的数据放入括号中
            System.out.print("[");
            for (int j = arr.length-i; j < arr.length; j++) {
                System.out.print(arr[j]+" ");
            }
            System.out.println("]");
        }
        }

}
